/*
 * MemCounter.h
 *
 *  Created on: 05/08/2013
 *      Author: marcio
 */

#ifndef MEMCOUNTER_H_
#define MEMCOUNTER_H_

class MemCounter {

	double memcur;
	double maxmem;
	double maxalloc;

public:
	MemCounter();

	virtual ~MemCounter();

	void alloc(double value);

	void free(double value);

	double getMaxMem();

	double getMaxAlloc();

};

MemCounter::MemCounter(){
	memcur = 0;
	maxmem = 0;
	maxalloc = 0;
}

MemCounter::~MemCounter(){

}

void MemCounter::alloc(double value){
	memcur += value;
	if(value > maxalloc) maxalloc = value;
	if(memcur > maxmem) maxmem = memcur;
}

void MemCounter::free(double value){
	memcur -= value;
}

double MemCounter::getMaxMem(){
	return maxmem;
}

double MemCounter::getMaxAlloc(){
	return maxalloc;
}

#endif /* MEMCOUNTER_H_ */
